import Vue from 'vue'

import Cookies from 'js-cookie'

import 'normalize.css/normalize.css' // a modern alternative to CSS resets

import VueQr from 'vue-qr'
import Element from 'element-ui'
import './styles/element-variables.scss'

import dayjs from 'dayjs'
import math from '@/utils/math'

import '@/styles/index.scss' // global css

import App from './App'
import store from './store'
import router from './router'

import './icons' // icon
import './permission' // permission control
import './utils/error-log' // error log

import components from './components' // global components
import * as filters from './filters' // global filters
import * as utils from './utils' // global functions

import Viewer from 'v-viewer'
import 'viewerjs/dist/viewer.css'

import axios from 'axios'
Vue.prototype.$axios = axios

Vue.use(Viewer, {
  defaultOptions: {
    zIndex: 9999,
    scalable: false
  }
})

Vue.use(VueQr)
Vue.use(Element, {
  size: Cookies.get('size') || 'medium' // set element-ui default size
  // locale: enLang // 如果使用中文，无需设置，请删除
})
// eslint-disable-next-line no-undef
Vue.prototype.$echarts = echarts
Vue.prototype.$dayjs = dayjs
Vue.prototype.$math = math

// register global components
Vue.use(components)
// register global utility filters
Object.keys(filters).forEach(key => {
  Vue.filter(key, filters[key])
})
// register global functions
Object.keys(utils).forEach(key => {
  Vue.prototype['$' + key] = utils[key]
})

Vue.config.productionTip = false

new Vue({
  el: '#app',
  router,
  store,
  render: h => h(App)
})
